Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | /** * API route for managing progression deferrals * * POST /api/curriculum/[playerId]/defer-progression * Body: { skillId: string } * Creates a 7-day deferral for the specified skill progression. * * DELETE /api/curriculum/[playerId]/defer-progression * Body: { skillId: string } * Removes the deferral for the specified skill. */ import { NextResponse } from 'next/server' import { withAuth } from '@/lib/auth/withAuth' import { canPerformAction } from '@/lib/classroom' import { clearDeferral, deferProgression } from '@/lib/curriculum/progression-deferrals' import { getUserId } from '@/lib/viewer' export const POST = withAuth(async (request, { params }) => { try { const { playerId } = (await params) as { playerId: string } const { skillId } = await request.json() if (!playerId || !skillId) { return NextResponse.json({ error: 'Player ID and skill ID required' }, { status: 400 }) } const userId = await getUserId() const canManage = await canPerformAction(userId, playerId, 'start-session') if (!canManage) { return NextResponse.json({ error: 'Not authorized' }, { status: 403 }) } const deferral = await deferProgression(playerId, skillId) return NextResponse.json({ deferral }) } catch (error) { console.error('Error deferring progression:', error) return NextResponse.json({ error: 'Failed to defer progression' }, { status: 500 }) } }) export const DELETE = withAuth(async (request, { params }) => { try { const { playerId } = (await params) as { playerId: string } const { skillId } = await request.json() if (!playerId || !skillId) { return NextResponse.json({ error: 'Player ID and skill ID required' }, { status: 400 }) } const userId = await getUserId() const canManage = await canPerformAction(userId, playerId, 'start-session') if (!canManage) { return NextResponse.json({ error: 'Not authorized' }, { status: 403 }) } await clearDeferral(playerId, skillId) return NextResponse.json({ success: true }) } catch (error) { console.error('Error clearing deferral:', error) return NextResponse.json({ error: 'Failed to clear deferral' }, { status: 500 }) } }) |